package com.moliku.insurance.process.service.impl;

import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.moliku.insurance.common.constant.CompanyEnum;
import com.moliku.insurance.common.constant.OrderEnum;
import com.moliku.insurance.common.constant.PolicyConfigKeyEnum;
import com.moliku.insurance.common.response.CommonInsureResult;
import com.moliku.insurance.common.util.XMLUtil;
import com.moliku.insurance.model.dto.CancelInsureDTO;
import com.moliku.insurance.model.dto.DownloadInsureDTO;
import com.moliku.insurance.model.dto.insure.InsureDTO;
import com.moliku.insurance.model.dto.insure.InsuredInfoDTO;
import com.moliku.insurance.model.entity.Order;
import com.moliku.insurance.model.entity.OrderDetail;
import com.moliku.insurance.model.entity.cpic.*;
import com.moliku.insurance.process.mapper.BaseOrderMapper;
import com.moliku.insurance.process.service.ConfigService;
import com.moliku.insurance.process.strategy.PolicyStrategy;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Base64;
import java.util.Date;
import java.util.List;

/**
 * 太平洋保险
 *
 * @author Mr.Liu
 * @since 2021/2/25
 */
@Slf4j
@AllArgsConstructor
@Service("CpicService")
public class CpicServiceImpl implements PolicyStrategy {

    /**
     * 太平洋保险的测试环境地址
     */
//    private static final String TARGET_URL = "https://jttpitxsit.cpic.com.cn/jttpitx/itxsvc/param";
    /**
     * 版本标识，固定值 3
     */
    private static final String MESSAGE_ROUTER = "3";
    /**
     * 合作伙伴编码，由太平洋保险指定，每个商户不一样
     */
//    private static final String PARTNER_CODE = "B5A";
    /**
     * 业务协议，固定值 CPIC_ECOM
     */
    private static final String DOCUMENT_PROTOCOL = "CPIC_ECOM";

    /**
     * 投保成功已生效的状态码
     */
    private static final String INSURED_SUCCESS_CODE = "2";
    /**
     * 响应成功的状态码
     */
    private static final String RESPONSE_SUCCESS_CODE = "000000";

    /**
     * 退保成功的状态码
     */
    private static final String CANCEL_SUCCESS_CODE = "00";

    @Autowired
    private BaseOrderMapper baseOrderMapper;

    @Autowired
    private ConfigService configService;

    @Override
    public CommonInsureResult submitPolicy(InsureDTO data) {
        try {
            //投保保单基本信息
            PolicyBaseInfo policyBaseInfo = new PolicyBaseInfo();
            //业务订单号
            policyBaseInfo.setUniqueFlag(data.getOrder().getSerialNumber());
            //分公司代码 终端号, 代表业务归属，由业务提供
//            policyBaseInfo.setTerminalNo(data.getOrder().getPartnerAccountCode());
            policyBaseInfo.setTerminalNo("3090100");
            //方案代码，业务配置方案并提供
//            policyBaseInfo.setPlanCode(data.getOrder().getPlanCode());
            policyBaseInfo.setPlanCode(data.getOrder().getProductCode());
            //团个单标志，以被保人人数判断 S个单 G团单  P团单个出
            policyBaseInfo.setGroupInsuranceFlag("S");
            //打印方式（0 电子保单,1 纸质保单，默认 0，特殊场景使用纸质保单）
            policyBaseInfo.setBillType("0");
            //承保分数
            policyBaseInfo.setCoverageCopies("1");
            policyBaseInfo.setStartDate(data.getOrder().getStartTime());
            policyBaseInfo.setEndDate(data.getOrder().getEndTime());

            //投保人信息
            CpicApplicant cpicApplicant = new CpicApplicant();
            cpicApplicant.setCustomerName(data.getPolicyHolder().getcName());
            cpicApplicant.setCertificateType(getCardType(data.getPolicyHolder().getCardType()));
            cpicApplicant.setCertificateCode(data.getPolicyHolder().getCardNo());
            cpicApplicant.setCustomerBirthday(data.getPolicyHolder().getBirthDay());
//            cpicApplicant.setComAddress(data.getPolicyHolder().getAddress());
            cpicApplicant.setMobile(data.getPolicyHolder().getMobile());
            cpicApplicant.setEmail(data.getPolicyHolder().getEmail());
            cpicApplicant.setCustomerGender(getSex(data.getPolicyHolder().getSex()));
            //cpicApplicant.setCustomerWithTheInsured(data.getPolicyHolder().getRelation());

            //被保人信息
            List<CpicInsuredList> cpicInsuredLists = new ArrayList<>();
            int i = 1;
            for (InsuredInfoDTO infoDTO : data.getInsureds()) {
                CpicInsured cpicInsured = new CpicInsured();
                //被保人编号
                cpicInsured.setInsuredCode(String.valueOf(i));
                i++;
                cpicInsured.setCustomerName(infoDTO.getCName());
                cpicInsured.setCertificateCode(infoDTO.getCardNo());
                cpicInsured.setCertificateType(getCardType(infoDTO.getCardType()));
                cpicInsured.setCustomerGender(getSex(infoDTO.getSex()));
                cpicInsured.setCustomerBirthday(infoDTO.getBirthDay());
                cpicInsured.setBenefitWay("1");
                CpicInsuredList cpicInsuredList = new CpicInsuredList();
                cpicInsuredList.setInsured(cpicInsured);
                cpicInsuredLists.add(cpicInsuredList);
            }

            //保单提交请求
            PolicyApplyRequest policyApplyRequest = new PolicyApplyRequest();
            policyApplyRequest.setPolicyBaseInfo(policyBaseInfo);
            policyApplyRequest.setApplicant(cpicApplicant);
            policyApplyRequest.setInsuredList(cpicInsuredLists);
            //电子保单关联信息
            policyApplyRequest.setEPolicyInfo(getEPolicyInfo());

            //请求body
            CpicCastBody cpicCastBody = new CpicCastBody();
            cpicCastBody.setPolicyApplyRequest(policyApplyRequest);

            //全部请求
            CpicRequest cpicRequest = new CpicRequest();
            //查询账号密码
            String username = configService.getConfigValue(CompanyEnum.CPIC, PolicyConfigKeyEnum.USERNAME);
            String password = configService.getConfigValue(CompanyEnum.CPIC, PolicyConfigKeyEnum.PASSWORD);
            String partnerCode = configService.getConfigValue(CompanyEnum.CPIC, PolicyConfigKeyEnum.PARTNER_ACCOUNT_CODE);
            //请求头
            cpicRequest.setHead(getCpicHead("108001", partnerCode, data.getOrder().getSerialNumber(), username, password));
            cpicRequest.setBody(cpicCastBody);

            // 将对象转换成string类型的xml
            String strXml = XMLUtil.convertToXml(cpicRequest);
            log.info("投保参数--{}", strXml);

            //发起请求
            String result = sentHttpPostRequest(strXml, partnerCode);
            log.info("投保响应--{}", result);
            //判断响应格式是否是XML类型
            if (!XMLUtil.isXmlDocument(result)) {
                return CommonInsureResult.submitPolicyFail("太平洋保险响应内容异常！");
            }
            //xml转json
            JSONObject jsonObject = JSONUtil.xmlToJson(result);
            log.info("xml转json--{}", jsonObject.toString());
            Order order = baseOrderMapper.selectById(data.getLocalOrderId());
            OrderDetail orderDetail = baseOrderMapper.selectDeatailByOrderId(order.getId());
            orderDetail.setInsureRsp(jsonObject.toString());
            baseOrderMapper.updateOrderDeatailByOrderId(orderDetail);
            String head = JSONUtil.parseObj(jsonObject.get("response")).isNull("head") ? "" : JSONUtil.parseObj(jsonObject.get("response")).get("head").toString();
            String body = JSONUtil.parseObj(jsonObject.get("response")).isNull("body") ? "" : JSONUtil.parseObj(jsonObject.get("response")).get("body").toString();
            String policyNo = "";
            //响应内容都不空
            if (!StringUtils.isBlank(head) && !StringUtils.isBlank(body)) {
                String responseCompleteMessageStatus = JSONUtil.parseObj(head).get("responseCompleteMessageStatus").toString();
                String messageStatusCode = JSONUtil.parseObj(responseCompleteMessageStatus).get("messageStatusCode").toString();
                //接口响应00000代表成功
                if (RESPONSE_SUCCESS_CODE.equals(messageStatusCode)) {
                    //获取保单号
                    policyNo = JSONUtil.parseObj(body).getJSONObject("PolicyApplyResponse").get("policyNo").toString();
                    //获取保单状态
                    String policyStatus = JSONUtil.parseObj(body).getJSONObject("PolicyApplyResponse").get("policyStatus").toString();
                    if (INSURED_SUCCESS_CODE.equals(policyStatus)) {
                        //保单2为保单已生效
                        order.setPolicyNo(policyNo);
                        order.setStatus(OrderEnum.CLOSED_NO_REFUND.getValue());
                        baseOrderMapper.updateById(order);
                    }
                } else {
                    String msg = JSONUtil.parseObj(head).getJSONObject("responseCompleteMessageStatus").getJSONObject("messageStatusDescriptionList").getJSONObject("messageStatusDescription").get("messageStatusSubDescription").toString();
                    return CommonInsureResult.submitPolicyFail(msg);
                }
            } else {
                String msg = JSONUtil.parseObj(head).getJSONObject("responseCompleteMessageStatus").getJSONObject("messageStatusDescriptionList").getJSONObject("messageStatusDescription").get("messageStatusSubDescription").toString();
                return CommonInsureResult.submitPolicyFail(msg);
            }
            return CommonInsureResult.submitPolicySuccess(policyNo);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return CommonInsureResult.submitPolicyFail();
    }

    @Override
    public CommonInsureResult cancelPolicy(CancelInsureDTO data) {
        try {
            //批单基本信息节点
            PolicyCancellationBaseInfo policyCancellationBaseInfo = new PolicyCancellationBaseInfo();
            policyCancellationBaseInfo.setPolicyNo(data.getPolicyNo());
            policyCancellationBaseInfo.setApplicationReason("行程取消");
            policyCancellationBaseInfo.setBillType("0");

            Order orderInfo = baseOrderMapper.selectByPolicyNo(data.getPolicyNo());
            OrderDetail orderDetail = baseOrderMapper.selectDeatailByOrderId(orderInfo.getId());
            JSONObject detailObject = JSONUtil.parseObj(orderDetail.getData());
            Proposer proposer = new Proposer();
            //申请人名称
            proposer.setCustomerName(detailObject.getJSONObject("policyHolder").get("cName").toString());
            //证件类型
            proposer.setCertificateType(detailObject.getJSONObject("policyHolder").get("cardType").toString());
            //证件号码
            proposer.setCertificateCode(detailObject.getJSONObject("policyHolder").get("cardNo").toString());

            //请求体内容
            PolicyCancellationRequest policyCancellationRequest = new PolicyCancellationRequest();
            //默认分公司代码，终端号, 代表业务归属，由业务提供
            policyCancellationRequest.setTerminalNo("3090100");
            policyCancellationRequest.setPolicyCancellationBaseInfo(policyCancellationBaseInfo);
            policyCancellationRequest.setProposer(proposer);
            policyCancellationRequest.setEPolicyInfo(getEPolicyInfo());

            CpicQuitBody cpicQuitBody = new CpicQuitBody();
            cpicQuitBody.setPolicyCancellationRequest(policyCancellationRequest);

            //全部请求
            CpicQuitRequest cpicQuitRequest = new CpicQuitRequest();
            //查询账号密码
            String username = configService.getConfigValue(CompanyEnum.CPIC, PolicyConfigKeyEnum.USERNAME);
            String password = configService.getConfigValue(CompanyEnum.CPIC, PolicyConfigKeyEnum.PASSWORD);
            String partnerCode = configService.getConfigValue(CompanyEnum.CPIC, PolicyConfigKeyEnum.PARTNER_ACCOUNT_CODE);
            //请求头
            cpicQuitRequest.setHead(getCpicHead("108003", partnerCode, data.getPolicyNo(), username, password));
            cpicQuitRequest.setBody(cpicQuitBody);
            // 将对象转换成string类型的xml
            String strXml = XMLUtil.convertToXml(cpicQuitRequest);
            log.info("请求XML--{}", strXml);
            //发起请求
            String result = sentHttpPostRequest(strXml, partnerCode);
            log.info("退保响应--{}", result);
            //判断响应格式是否是XML类型
            if (!XMLUtil.isXmlDocument(result)) {
                return CommonInsureResult.cancelPolicyFail("太平洋保险响应异常！");
            }
            //xml转json
            JSONObject jsonObject = JSONUtil.xmlToJson(result);
            log.info("xml转json--{}", jsonObject.toString());
            OrderDetail orderDetaill = baseOrderMapper.selectDeatailByOrderId(orderInfo.getId());
            orderDetaill.setCancelPolicyRsp(jsonObject.toString());
            baseOrderMapper.updateOrderDeatailByOrderId(orderDetaill);
            String head = JSONUtil.parseObj(jsonObject.get("response")).isNull("head") ? "" : JSONUtil.parseObj(jsonObject.get("response")).get("head").toString();
            String body = JSONUtil.parseObj(jsonObject.get("response")).isNull("body") ? "" : JSONUtil.parseObj(jsonObject.get("response")).get("body").toString();
            String resultCode = "";
            //响应内容都不空
            if (!StringUtils.isBlank(head) && !StringUtils.isBlank(body)) {
                String messageStatusCode = JSONUtil.parseObj(head).getJSONObject("responseCompleteMessageStatus").get("messageStatusCode").toString();
                //接口响应00000代表成功
                if (RESPONSE_SUCCESS_CODE.equals(messageStatusCode)) {
                    resultCode = JSONUtil.parseObj(body).getJSONObject("PolicyApplyResponse").get("resultCode").toString();
                    //获取退保状态
                    if (StringUtils.isBlank(resultCode) || CANCEL_SUCCESS_CODE.equals(resultCode)) {
                        //00 或空值退保成功
                        //更改订单状态
                        orderInfo.setStatus(OrderEnum.CANCEL.getValue());
                        baseOrderMapper.updateById(orderInfo);
                    } else {
                        return CommonInsureResult.cancelPolicyFail(returnMsg(resultCode));
                    }
                } else {
                    String message = JSONUtil.parseObj(head).getJSONObject("responseCompleteMessageStatus").get("messageStatusSubDescription").toString();
                    return CommonInsureResult.cancelPolicyFail();
                }
            } else {
                String message = JSONUtil.parseObj(head).getJSONObject("responseCompleteMessageStatus").get("messageStatusSubDescription").toString();
                return CommonInsureResult.cancelPolicyFail();
            }
            return CommonInsureResult.cancelPolicySuccess();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return CommonInsureResult.cancelPolicyFail();
    }

    @Override
    public CommonInsureResult downloadPolicy(DownloadInsureDTO downloadInsure) {
        try {

            EpolicyInfoReprint epolicyInfoReprint = new EpolicyInfoReprint();
            epolicyInfoReprint.setEmailFlag("0");
            epolicyInfoReprint.setMessageFlag("0");
            epolicyInfoReprint.setPolicyNo(downloadInsure.getPolicyNo());
            epolicyInfoReprint.setReturnPDFFlag("1");

            //请求body
            CpicDownloadBody cpicDownloadBody = new CpicDownloadBody();
            cpicDownloadBody.setEpolicyInfoReprint(epolicyInfoReprint);

            //全部请求
            CpicDownloadRequest cpicDownloadRequest = new CpicDownloadRequest();
            //查询账号密码
            String username = configService.getConfigValue(CompanyEnum.CPIC, PolicyConfigKeyEnum.USERNAME);
            String password = configService.getConfigValue(CompanyEnum.CPIC, PolicyConfigKeyEnum.PASSWORD);
            String partnerCode = configService.getConfigValue(CompanyEnum.CPIC, PolicyConfigKeyEnum.PARTNER_ACCOUNT_CODE);
            //请求头
            cpicDownloadRequest.setHead(getCpicHead("108005", partnerCode, downloadInsure.getPolicyNo(), username, password));
            cpicDownloadRequest.setBody(cpicDownloadBody);
            // 将对象转换成string类型的xml
            String strXml = XMLUtil.convertToXml(cpicDownloadRequest);
            log.info("下载请求体--{}", strXml);
            //发起请求
            String result = sentHttpPostRequest(strXml, partnerCode);
            log.info("下载响应--{}", result);
            //判断响应格式是否是XML类型
            if (!XMLUtil.isXmlDocument(result)) {
                return CommonInsureResult.downloadPolicyFail("太平洋保险响应异常！");
            }
            //xml转json
            JSONObject jsonObject = JSONUtil.xmlToJson(result);
            log.info("xml转json--{}", jsonObject.toString());
            String head = JSONUtil.parseObj(jsonObject.get("response")).isNull("head") ? "" : JSONUtil.parseObj(jsonObject.get("response")).get("head").toString();
            String body = JSONUtil.parseObj(jsonObject.get("response")).isNull("body") ? "" : JSONUtil.parseObj(jsonObject.get("response")).get("body").toString();
            byte[] bytes = null;
            //响应内容都不空
            if (!StringUtils.isBlank(head) && !StringUtils.isBlank(body)) {
                String messageStatusCode = JSONUtil.parseObj(head).getJSONObject("responseCompleteMessageStatus").get("messageStatusCode").toString();
                //接口响应00000代表成功
                if (RESPONSE_SUCCESS_CODE.equals(messageStatusCode)) {
                    //获取下载文件流
                    String epolicyPDF = JSONUtil.parseObj(body).getJSONObject("epolicyInfoReprintResponse").get("epolicyPDF").toString();
                    bytes = Base64.getDecoder().decode(epolicyPDF);
                    if (null == bytes || bytes.length == 0) {
                        return CommonInsureResult.downloadPolicyFail();
                    }
                } else {
                    String message = JSONUtil.parseObj(head).getJSONObject("responseCompleteMessageStatus").getJSONObject("messageStatusDescriptionList").getJSONObject("messageStatusDescription").get("messageStatusSubDescription").toString();
                    return CommonInsureResult.downloadPolicyFail(message);
                }
            } else {
                String message = JSONUtil.parseObj(head).getJSONObject("responseCompleteMessageStatus").getJSONObject("messageStatusDescriptionList").getJSONObject("messageStatusDescription").get("messageStatusSubDescription").toString();
                return CommonInsureResult.downloadPolicyFail(message);
            }
            return CommonInsureResult.downloadPolicySuccess(bytes);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return CommonInsureResult.downloadPolicyFail();
    }

    /**
     * @Description: 封装请求 文档中给的示例
     * @Param: requestMsg 请求报文
     * @Param: partnerCode 合作方代码
     * @Author: yws
     * @Date: 2021/3/5 10:10
     */
    public String sentHttpPostRequest(String requestMsg, String partnerCode) throws IOException {
        String targetUrl = configService.getConfigValue(CompanyEnum.CPIC, PolicyConfigKeyEnum.SUBMIT_POLICY_URL);
        HttpClient httpclient = HttpClientBuilder.create().build();
        // 注意：必须以post方式发送请求
        HttpPost httpPost = new HttpPost(targetUrl);
        // 设置超时时间
        int timeout = 60000;
        RequestConfig config = RequestConfig.custom().setConnectTimeout(timeout).setSocketTimeout(timeout).build();
        //4.3之后设置超时的方式
        httpPost.setConfig(config);
        // 设置请求参数
        List<NameValuePair> params = new ArrayList<NameValuePair>();
        // 版本标识
        params.add(new BasicNameValuePair("messageRouter", MESSAGE_ROUTER));
        // 业务伙伴代码
        params.add(new BasicNameValuePair("tradingPartner", partnerCode));
        // 业务协议
        params.add(new BasicNameValuePair("documentProtocol", DOCUMENT_PROTOCOL));
        // xml请求报文
        params.add(new BasicNameValuePair("requestMessage", requestMsg));
        // 注意：编码必须是UTF-8
        HttpEntity request = new UrlEncodedFormEntity(params, "UTF-8");
        httpPost.setEntity(request);
        // 返回内容为xml，请使用xml解析工具对返回内容进行解析
        HttpResponse httpResponse = httpclient.execute(httpPost);
        HttpEntity entity = httpResponse.getEntity();
        String result = null;
        if (entity != null) {
            result = EntityUtils.toString(entity);
        }
        return result;
    }

    /**
     * @Description: 请求头信息
     * @Param: transactionCode 业务交易码，意外险承保接口 108001 意外险保单全额退保接口 108003 意外险电子保单下载接口 108005
     * @Param: partnerCode 合作伙伴编码,由太保指定，每个商户不一样
     * @Param: messageId 交易流水号
     * @Param: user 合作方用户，由太保为每个合作方指定
     * @Param: password 用户密码，由太保为每个合作方指定
     * @Return: CpicHead 请求头信息
     * @Author: yws
     * @Date: 2021/3/9 15:26
     */
    private static CpicHead getCpicHead(String transactionCode, String partnerCode, String messageId, String user, String password) {
        CpicHead cpicHead = new CpicHead();
        //投保固定值
        cpicHead.setTransactionCode(transactionCode);
        //合作伙伴编码,由太保指定，每个商户不一样
        cpicHead.setPartnerCode(partnerCode);
        //交易流水号
        cpicHead.setMessageId(messageId);
        //交易时间 ：yyyy-MM-dd HH:mm:ss 需要使用当天日期，否则系统会拦截投保失败
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        cpicHead.setTransactionEffectiveDate(sdf.format(new Date()));
        cpicHead.setUser(user);
        cpicHead.setPassword(password);
        return cpicHead;
    }

    /**
     * @Description: 投保和退保时电子保单关联信息
     * @Param:
     * @Return:
     * @Author: yws
     * @Date: 2021/3/9 16:00
     */
    private static EPolicyInfo getEPolicyInfo() {
        //电子保单关联信息
        EPolicyInfo ePolicyInfo = new EPolicyInfo();
        //短信发送标志 0 不发送，1 发送
        ePolicyInfo.setMessageFlag("0");
        //短信接收手机号
        ePolicyInfo.setElectronPolicyMobile("");
        //邮件发送标志 0 不发送，1 发送
        ePolicyInfo.setEmailFlag("0");
        //电子保单接收邮箱
        ePolicyInfo.setElectronPolicyEmail("");
        //是否返回 pdf 字节流 1 返回 0 或空
        ePolicyInfo.setReturnPDFFlag("0");
        return ePolicyInfo;
    }

    /**
     * @Description: 返回身份证类型
     * @Param: cardType
     * @Return: String
     * @Author: yws
     * @Date: 2021/3/6 10:58
     */
    private static String getCardType(String cardType) {
        switch (cardType) {
            //身份证
            case "1":
                return "1";
            //护照
            case "3":
                return "2";
            //港澳台居住证
            case "15":
                return "h";
            //组织机构代码
            case "72":
                return "4";
            //营业证号
            case "70":
                return "5";
            //其他
            default:
                return "3";
        }
    }

    /**
     * @Description: 返回性别
     * @Param: sex
     * @Return: String
     * @Author: yws
     * @Date: 2021/3/6 10:58
     */
    private static String getSex(String sex) {
        switch (sex) {
            //男
            case "1":
                return "1";
            //女
            case "0":
                return "2";
            //未知
            default:
                return "0";
        }
    }

    /**
     * @Description: 返回错误信息
     * @Author: yws
     * @Date: 2021/3/6 10:58
     */
    private static String returnMsg(String code) {
        switch (code) {
            case "01":
                return "退保失败：保单不存在";
            case "02":
                return "退保失败：保单已退保";
            case "03":
                return "退保失败：保单状态不是已生效不能做退保";
            case "04":
                return "退保失败：保单已起保不能做退保";
            case "05":
                return "退保失败：保单批改中不能做退保";
            default:
                return "退保失败：未知原因！";
        }
    }


}
